package oocl.eshop.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.activemq.util.IndentPrinter;

/**
 * Servlet implementation class Paging
 */
public class Paging extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Paging() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int curPage=Integer.parseInt(request.getParameter("targetPage"));
		HttpSession sen=request.getSession();
		int  pageSum=(int) sen.getAttribute("pageSum");
		if (curPage==0) {
			curPage=1;
		}
		if(curPage > pageSum){
			curPage=pageSum;
			
		};
		
		sen.setAttribute("curPage", curPage);
		
		request.getRequestDispatcher("merManage.jsp").forward(request, response);
		
		
	}

}
